<template>
    <div>
        <div class="content">
            <ul class="list">
                <li v-for="(item,index) in result3" :key="index">
                    <ul>
                        <li>
                            <img :src="item.logo" width="90px" height="90px" style="border-radius:50%;">
                            <img :src="smallIcon(index)" width="26px" height="26px" v-if="smallIcon(index)">
                        </li>
                        <li>
                            <p>{{title1(index)}}</p>
                            <p>{{content1(index)}}</p>
                        </li>
                        <li>
                            <p>所属类别</p>
                            <p>{{sslb(index)}}</p>
                        </li>
                        <li>
                            <p>{{title2(index)}}</p>
                            <p>{{content2(index)}}</p>
                        </li>
                        <li>
                            <p>{{title3(index)}}</p>
                            <p>{{content3(index)}}</p>
                        </li>
                        <li>
                            <p>{{title4(index)}}</p>
                            <p>{{content4(index)}}</p>
                        </li>
                        <li>
                            <p>参考价格</p>
                            <p>{{content5(index)}}元起</p>
                        </li>
                        <li>
                            <div><button @click="addctrl(index)">{{ctrlName}}</button></div>
                            <div><button @click="$router.push({path:'/view2/shortVideoDetail',query:{id:item.id }})">查看详情</button></div>
                        </li>
                    </ul>
                </li>
            </ul>
            <el-pagination class="page"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="5"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
            </el-pagination>
        </div>
    </div>
</template>
<script>
const img1 = require("../../assets/img/热销媒体列表/切图/1.png");
const img2 = require("../../assets/img/热销媒体列表/切图/2.png");
const img4 = require("../../assets/img/热销媒体列表/切图/4.png");
const img8 = require("../../assets/img/热销媒体列表/切图/8.png");
const img5 = require("../../assets/img/热销媒体列表/切图/5.png");
const img9 = require("../../assets/img/热销媒体列表/切图/9.png");
const img10 = require("../../assets/img/收藏夹/切图/4.png");
const img11 = require("../../assets/img/收藏夹/切图/5.png");
const img12 = require("../../assets/img/收藏夹/切图/6.png");
const img13 = require("../../assets/img/收藏夹/切图/7.png");
const img14 = require("../../assets/img/收藏夹/切图/8.png");
export default {
  data() {
    return {
      showMedia: true,
      navList1: [
        [img5, "综合", img9],
        [img5, "人气", img9],
        [img5, "价格", img9]
      ],
      index3: 0,
      input1: "",
      // 列表一需要显示默认进行勾选的。
      index1: 0,
      // 列表一需要显示默认进行勾选的。
      index2: 0,
      // 路由参数type，默认勾选
      type: "",
      // 查询结果1
      result1: "",
      // 查询结果2
      result2: "",
      // 查询结果3
      result3: "",
      // 展开显示数据
      resultBefore: "",
      // 默认勾选样式
      imgDef: img1,
      // 选中样式
      imgCli: img2,
      name: "点击展开",
      src: img8,
      key: 6,
      page: 1,
      limit: 10,
      order: "",
      sort: "ASC",
      orderList: ["03", "01", "02"],
      // 分页总条数
      total: 0,
      ctrlName: "加入收藏夹",
      str: ""
    };
  },
  computed: {
    args() {
      return {
        str: this.str,
        page: this.page,
        limit: this.limit
      };
    }
  },
  methods: {
    imgSelect1(index) {
      if (index == this.index1) {
        return this.imgDef;
      } else {
        return this.imgCli;
      }
    },
    handleSizeChange(val) {
      this.limit = val;
      this.$ajax
        .post(this.Ipurl + "popularMedia/search", this.args)
        .then(res => {
          this.result3 = res.data.dataInfo.records;
          this.total = res.data.dataInfo.total;
        });
    },
    handleCurrentChange(val) {
      this.page = val;
      this.$ajax
        .post(this.Ipurl + "popularMedia/search", this.args)
        .then(res => {
          this.result3 = res.data.dataInfo.records;
          this.total = res.data.dataInfo.total;
        });
    },
    sslb(index) {
      return this.result3[index].type;
    },
    smallIcon(index) {
      if (this.result3[index].type == "短视频") {
        return img10;
      } else if (this.result3[index].type == "小红书号") {
        return img11;
      } else if (this.result3[index].type == "网易考拉海购号") {
        return img12;
      } else if (this.result3[index].type == "微信公众号") {
        return img13;
      } else if (this.result3[index].type == "微博大V号") {
        return img14;
      } else if (this.result3[index].type == "app") {
        return null;
      }
    },
    title1(index) {
      return this.result3[index].mediaName;
    },
    title2(index) {
      if (this.result3[index].type == "短视频") {
        return "所属平台";
      } else if (this.result3[index].type == "小红书号") {
        return "粉丝数";
      } else if (this.result3[index].type == "网易考拉海购号") {
        return "获赞量";
      } else if (this.result3[index].type == "微信公众号") {
        return "ID";
      } else if (this.result3[index].type == "微博大V号") {
        return "粉丝数";
      } else if (this.result3[index].type == "app") {
        return "月活";
      }
    },
    title3(index) {
      if (this.result3[index].type == "短视频") {
        return "ID";
      } else if (this.result3[index].type == "小红书号") {
        return "点赞/收藏";
      } else if (this.result3[index].type == "网易考拉海购号") {
        return "粉丝数";
      } else if (this.result3[index].type == "微信公众号") {
        return "平均阅读量";
      } else if (this.result3[index].type == "微博大V号") {
        return "平均转发量";
      } else if (this.result3[index].type == "app") {
        return "媒体领域";
      }
    },
    title4(index) {
      if (this.result3[index].type == "短视频") {
        return "粉丝数";
      } else if (this.result3[index].type == "小红书号") {
        return "笔记数量";
      } else if (this.result3[index].type == "网易考拉海购号") {
        return "文章数";
      } else if (this.result3[index].type == "微信公众号") {
        return "粉丝数";
      } else if (this.result3[index].type == "微博大V号") {
        return "平均点赞量";
      } else if (this.result3[index].type == "app") {
        return "售卖方式";
      }
    },
    content1(index) {
      return this.result3[index].about;
    },
    content2(index) {
      if (this.result3[index].type == "短视频") {
        return this.result3[index].platformName;
      } else if (this.result3[index].type == "小红书号") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "网易考拉海购号") {
        return this.numLen(this.result3[index].likenumInt + "");
      } else if (this.result3[index].type == "微信公众号") {
        return this.result3[index].userId;
      } else if (this.result3[index].type == "微博大V号") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "app") {
        return this.numLen(this.result3[index].monthToLive + "");
      }
    },
    content3(index) {
      if (this.result3[index].type == "短视频") {
        return this.result3[index].userId;
      } else if (this.result3[index].type == "小红书号") {
        return this.numLen(this.result3[index].likenumInt + "");
      } else if (this.result3[index].type == "网易考拉海购号") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "微信公众号") {
        return this.numLen(this.result3[index].readingQuantity + "");
      } else if (this.result3[index].type == "微博大V号") {
        return this.numLen(this.result3[index].amountOfForwarding + "");
      } else if (this.result3[index].type == "app") {
        return this.numLen(this.result3[index].mediaSectorStr + "");
      }
    },
    content4(index) {
      if (this.result3[index].type == "短视频") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "小红书号") {
        return this.numLen(this.result3[index].noteTheNumber + "");
      } else if (this.result3[index].type == "网易考拉海购号") {
        return this.numLen(this.result3[index].articleNum + "");
      } else if (this.result3[index].type == "微信公众号") {
        return this.numLen(this.result3[index].fansTotal + "");
      } else if (this.result3[index].type == "微博大V号") {
        return this.numLen(this.result3[index].likenumInt + "");
      } else if (this.result3[index].type == "app") {
        return this.numLen(this.result3[index].sellingWay + "");
      }
    },
    content5(index) {
      if (
        this.result3[index].type == "短视频" ||
        this.result3[index].type == "小红书号" ||
        this.result3[index].type == "网易考拉海购号" ||
        this.result3[index].type == "微信公众号" ||
        this.result3[index].type == "微博大V号"
      ) {
        return this.result3[index].referencePrice;
      } else {
        return this.result3[index].appPrice;
      }
    },
    // 收藏夹
    addctrl(index) {
      if (this.ctrlName == "加入收藏夹") {
        // 是否登录，加入收藏夹
        if (window.sessionStorage.getItem("userInfo")) {
          if (this.ctrlName == "加入收藏夹") {
            this.$ajax
              .post(this.Ipurl + "favoriteInfo/save", {
                userId: JSON.parse(window.sessionStorage.getItem("userInfo"))
                  .userId,
                popularMediaId: this.result3[index].id,
                type: this.result3[index].type
              })
              .then(res => {
                if (res.data.returnCode == 1000) {
                  this.$message("添加成功");
                  this.ctrlNum++;
                  this.ctrlName = "已经加入";
                } else {
                  this.$message.error("添加失败");
                }
              });
          } else {
            this.$message.error("不可以重复添加");
          }
        } else {
          this.$confirm("检测到您并没有登录", "warning", {
            confirmButtonText: "立即登录",
            cancelButtonText: "不了，谢谢",
            type: "warning"
          }).then(() => {
            this.$router.push("/login");
          });
        }
      }
    }
  },
  watch: {
    $route(to, from) {
      if (to.query.str) {
        this.str = to.query.str;
        this.$ajax
          .post(this.Ipurl + "popularMedia/search", { str: this.str })
          .then(res => {
            this.result3 = res.data.dataInfo.records;
            this.total = res.data.dataInfo.total;
          });
      }
    }
  },
  mounted() {
    this.str = this.$route.query.str;
    this.$ajax
      .post(this.Ipurl + "popularMedia/search", { str: this.str })
      .then(res => {
        this.result3 = res.data.dataInfo.records;
        this.total = res.data.dataInfo.total;
      });
  }
};
</script>
<style scoped>
.container {
  width: 1200px;
  margin: 0 auto;
  margin-top: 50px;
  overflow: hidden;
  background: #fff;
}
.nav1 {
  overflow: hidden;
}
.nav1 > div {
  float: left;
  width: 150px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}
.nav1 > div > span {
  margin-left: 20px;
  font-size: 16px;
  font-weight: bold;
}
.nav1 > ul {
  float: left;
  overflow: hidden;
}
.nav1 > ul > li {
  float: left;
  width: 170px;
  height: 60px;
  line-height: 60px;
  font-size: 16px;
  cursor: pointer;
}
.nav1 > ul > li > span {
  margin-left: 5px;
}
.nav1 > ul > li > span.red {
  color: rgb(237, 64, 64);
}
.nav1 > ul > li > span.black {
  color: rgb(34, 34, 34);
}
.nav2 > div {
  float: left;
  width: 150px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}
.nav2 > div > span {
  margin-left: 20px;
  font-size: 16px;
  font-weight: bold;
}
.nav2 > ul {
  float: left;
  overflow: hidden;
  width: 1050px;
}
.nav2 > ul > li {
  float: left;
  width: 170px;
  height: 60px;
  line-height: 60px;
  font-size: 16px;
  cursor: pointer;
  overflow: hidden;
}
.nav2 > ul > li > span {
  margin-left: 10px;
}
.nav2 > ul > li > span.red {
  color: rgb(237, 64, 64);
}
.nav2 > ul > li > span.black {
  color: rgb(34, 34, 34);
}
.nav2 > div:nth-child(3) {
  width: 100%;
  text-align: center;
  height: 24px;
  line-height: 24px;
  background: rgb(237, 64, 64);
  cursor: pointer;
}
.nav2 > div:nth-child(3) > span {
  font-size: 16px;
  color: #fff;
  margin-left: 8px;
}
.nav2 > div:nth-child(3) > img {
  margin-top: -5px;
}
.content {
  width: 1200px;
  margin: 0 auto;
  margin-top: 20px;
  overflow: hidden;
}
.list {
  overflow: hidden;
}
.list > li > ul > li {
  float: left;
  height: 200px;
  margin-top: 20px;
  background: #fff;
}
.list > li > ul > li:nth-child(1) {
  width: 190px;
  text-align: center;
  line-height: 200px;
  position: relative;
}
.list > li > ul > li:nth-child(1) > img:nth-child(2) {
  /* 下侧小图 */
  position: absolute;
  top: 115px;
  right: 50px;
}
.list > li > ul > li:nth-child(2) {
  width: 285px;
}
.list > li > ul > li:nth-child(2) > p:nth-child(1) {
  font-size: 18px;
  font-weight: bold;
  margin-top: 76px;
}
.list > li > ul > li:nth-child(2) > p:nth-child(2) {
  font-size: 14px;
  font-weight: bold;
  margin-top: 20px;
  color: rgb(34, 34, 34);
}
.list > li > ul > li:nth-child(3),
.list > li > ul > li:nth-child(4),
.list > li > ul > li:nth-child(5),
.list > li > ul > li:nth-child(6),
.list > li > ul > li:nth-child(7) {
  width: 100px;
  height: 200px;
  text-align: center;
}
.list > li > ul > li > p:nth-child(1) {
  font-size: 14px;
  font-weight: bold;
  margin-top: 76px;
}
.list > li > ul > li > p:nth-child(2) {
  font-size: 16px;
  font-weight: bold;
  margin-top: 20px;
  color: rgb(237, 64, 64);
}
.list > li > ul > li:last-child {
  width: 200px;
}
.list > li > ul > li:last-child > div {
  text-align: center;
}
.list > li > ul > li:last-child > div:nth-child(2) > button {
  width: 100px;
  height: 30px;
  border: 1px solid rgb(34, 34, 34);
  border-radius: 15px;
  margin-top: 16px;
  font-size: 14px;
  font-weight: bold;
  background: #fff;
}
.list > li > ul > li:last-child > div:nth-child(1) > button {
  width: 100px;
  height: 30px;
  border-radius: 15px;
  margin-top: 20px;
  color: #fff;
  background: rgb(237, 64, 64);
  font-size: 14px;
  font-weight: bold;
}
.page {
  margin-left: 250px;
}
.nav3 {
  width: 1200px;
  margin: 0 auto;
  margin-top: 20px;
  overflow: hidden;
  background: #fff;
}
.nav3 > div:nth-child(1) {
  float: left;
  width: 150px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}
.nav3 > div:nth-child(1) > span {
  margin-left: 20px;
  font-size: 16px;
  font-weight: bold;
}
.nav3 > ul {
  float: left;
  overflow: hidden;
}
.nav3 > ul > li {
  float: left;
  width: 170px;
  height: 60px;
  line-height: 60px;
  font-size: 16px;
  cursor: pointer;
}
.nav3 > ul > li > span {
  margin-left: 10px;
}
.nav3 > ul > li > span.red {
  color: rgb(237, 64, 64);
}
.nav3 > ul > li > span.black {
  color: rgb(34, 34, 34);
}
.nav3 > div:nth-child(3) {
  float: right;
  position: relative;
}
.nav3 > div:nth-child(3) > input {
  width: 268px;
  height: 32px;
  border: 1px solid rgb(237, 64, 64);
  margin-top: 10px;
  margin-right: 50px;
  border-radius: 10px 0 0 10px;
  padding-left: 15px;
}
.nav3 > div:nth-child(3) > div {
  width: 32px;
  height: 32px;
  text-align: center;
  line-height: 32px;
  position: absolute;
  top: 10px;
  right: 18px;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  background: rgb(237, 64, 64);
}
</style>



